<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class  ArticleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'title' => ['required', 'between:2,6',
                Rule::unique('articles')->ignore(request('article'))],
        ];
    }

    public function messages()
    {
        return [
            'title.required' => '标题不能为空',
            'title.between' => '标题必须是2-6个字符'
        ];
    }
}
